import httpInstance from "@/utils/http";

// 获取文章分类列表
export const getArticleCategoryAPI = () => {
    // 在pinia中定义响应式数据，不需要.value
    // 请求拦截器中，添加token，接口就不需要添加
    // const tokenStore = useTokenStore()
    // return httpInstance({
    //     url: '/category',
    //     method: 'GET',
    //     headers: {
    //         Authorization: tokenStore.token
    //     }
    // })

    return httpInstance({
        url: '/category',
        method: 'GET',
    })
}

// 添加文章分类
export const addArticleCategoryAPI = (data) => {
    return httpInstance({
        url: '/category',
        method: 'POST',
        data
    })
}

// 更新文章分类
export const updateArticleCategoryAPI = (data) => {
    return httpInstance({
        url: '/category',
        method: 'PUT',
        data
    })
}

// 删除文章分类
export const deleteArticleCategoryAPI = (id) => {
    return httpInstance({
        url: `/category?id=${id}`,
        method: 'DELETE'
    })
}

// 获取文章列表
export const getArticleListAPI = (params) => {
    return httpInstance({
        url: '/article',
        method: 'GET',
        params
    })
}

// 添加文章
export const addArticleAPI = (data) => {
    return httpInstance({
        url: '/article',
        method: 'POST',
        data
    })
}
